package com.itheima.demo5;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class IODemo6 {
    public static void main(String[] args) throws IOException {
        FileReader fileReader = new FileReader("a.txt");


        //空参构造方法
      /*  int ch;
        while ((ch = fileReader.read()) != -1){
            System.out.print((char)ch);
        }
        */

        //带参构造方法
        char[] chars = new char[2];
        int len;
        //read(chars):读取数据，解码，强转三步合并了，把强转之后的字符放到数组中
        while ((len = fileReader.read(chars)) != -1){
            System.out.print(new String(chars,0,len));
        }

        fileReader.close();

        fileReader.close();

    }
}
